<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
    String jname=request.getParameter("jname");
    String sname = request.getParameter("sname");
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新建方案</title>
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />
    <link rel="stylesheet" href="../css/jquery.cxcolor.css" />
    <script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../js/jquery.cxcolor.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div style="text-align: center">
    <h3 id="sname1"style="margin-left: -20px"></h3>
    <img id="WB"style=";width: 200px;height: 200px;border-radius: 5%"/><br>
    <button class="btn "style="margin-top: 10px"onclick="preview()">预览</button>
</div>

<div style="margin-top: 20px;" class="container-fluid">
    <button class="btn btn-primary" onclick="edit()"style="margin-left: 80px">修改方案</button>
    <form action="UserUpdateServlet" target="_self" method="post" enctype="multipart/form-data" class="form-horizontal" >
        <input id="jname" name="jname"type="hidden"class="form-control"style="width: 20%" type="text"/><br>
        <input id="sname" name="sname"type="hidden"class="form-control"style="width: 20%" type="text"/><br>
        <div class="row">
            <div class="col-md-1 col-xs-1"></div>
            <div class="col-md-2 col-xs-2 form-group">
                <div class="control-label col-md-5 "><label >经线</label></div>
                <div class="col-md-7 "><input id="WarpColor" name="WarpColor"class="form-control"style="font-size:0.2px"/></div>
            </div>
            <div class="col-md-2  col-xs-2 form-group">
                <div class="control-label col-md-5 col-lg-4" > <label>纬线1</label></div>
                <div class="col-md-7 col-lg-8"><input id="WeftColor1"name="WeftColor1"class="form-control"style="font-size:0.2px"/></div>
            </div>
            <div class="col-md-2 col-xs-2 form-group">
                <div class="control-label col-md-5"><label>纬线2</label></div>
                <div class="col-md-7"><input id="WeftColor2"name="WeftColor2"class="form-control"style="font-size: 0.2px"/></div>
            </div>
            <div class="col-md-2  col-xs-2 form-group">
                <div class="control-label col-md-5"><label>纬线3</label></div>
                <div class="col-md-7"><input id="WeftColor3"name="WeftColor3"class="form-control"style="font-size:0.2em"/></div>
            </div>
            <div class="col-md-2  col-xs-2 form-group ">
                <div class="control-label col-md-5"> <label>纬线4</label></div>
                <div class="col-md-7"><input id="WeftColor4"name="WeftColor4"class="form-control"style="font-size:0.2em"/></div>
            </div>
            <div class="col-md-1 col-xs-1"></div>
            <div class="col-md-6 col-xs-6 form-group">
                <div class="control-label col-md-4"><label for="MeiShu">枚&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数</label></div>
                <div class="col-md-4"><input type="text" name="MeiShu" id="MeiShu" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:16)</p>
            </div>
            <div class="col-md-6 col-xs-6 form-group">
                <div class="control-label col-md-4"><label for="FeiShu">飞&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数</label></div>
                <div class="col-md-4"><input type="text" name="FeiShu" id="FeiShu" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:5)</p>
            </div>
            <div class="col-md-6 col-xs-6  form-group ">
                <div class="control-label col-md-4"><label for="WidthResolution">宽度分辨率</label></div>
                <div class="col-md-4"><input type="text" name="WidthResolution" id="WidthResolution" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:6000)</p>
            </div>
            <div class="col-md-6 col-xs-6 form-group ">
                <div class="control-label col-md-4"><label for="WarpMiDu">经线密度</label></div>
                <div class="col-md-4"><input type="text" name="WarpMiDu" id="WarpMiDu" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:118)</p>
            </div>
            <div class="col-md-6 col-xs-6 form-group">
                <div class="control-label col-md-4"><label for="WeftMiDu">纬&nbsp;线&nbsp;密&nbsp;度</label></div>
                <div class="col-md-4"><input type="text" name="WeftMiDu" id="WeftMiDu" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:23)</p>
            </div>
            <div class="col-md-6 col-xs-6 form-group">
                <div class="control-label col-md-4"><label for="Squeeze">挤压程度</label></div>
                <div class="col-md-4"><input type="text" name="Squeeze" id="Squeeze" class="form-control"style="border-color:#888"/></div>
                <p>(建议取值:1)</p>
            </div>
            <div class="col-md-12"style="text-align: right">
                <input type="submit" class="btn btn-success" style="width: 80px;margin-right: 20px;" value="提交" >
            </div>
        </div>
    </form>

</div>
<button class="btn btn-primary" onclick="geturl()"style="margin-left: 80px">获取下载链接</button>
<div id="downloadurl"style="margin-left: 80px">
</div>
</div>
<script type="text/javascript">

    function geturl(){
        $.ajax({
            type:"get",
            url:"../userinfo/account",
            datatype:"json",
            success:function(data){
                if(data.account_type=="common") {
                    var flag = confirm("确认花费5元下载该纹版图吗？");
                    if(flag){
                        console.log(data.balance);
                        if(5>eval(data.balance)){
                            alert("余额不足，请先充值！");
                        }else {
                            console.log("普通用户下载");
                            /*var url = "<%=request.getContextPath()%>/scheme/load_WenBan?jname=" + '<%= jname%>'+"&sname="+ '<%=sname%>';
                            $("#pluginurl").attr("href",url);*/
                            $("#downloadurl").load("../downloadurl.jsp",{jname:'<%= jname%>',sname:'<%=sname%>'});
                        }
                    }
                }
                else {
                    console.log("VIP用户下载");
                    $("#downloadurl").load("../downloadurl.jsp",{jname:'<%= jname%>',sname:'<%=sname%>'});
                }
            }
        })
    }

    $(document).ready(function() {
        document.getElementById("sname1").innerHTML='<%=sname%>';
        document.getElementById("jname").value='<%=jname%>';
        document.getElementById("sname").value='<%=sname%>';
        $.ajax({
            type: "get",
            url: "/scheme/test?sname="+ '<%=sname%>'+"&jname="+'<%=jname%>',
            success: function(data) {
                document.getElementById("WB").src=data.yasuo;
                console.log(data.yasuo);
            //    var imgurl=data.url;
                var imgurl=data.yasuo;
                window.imgurl=imgurl;
            }
        });
        $('input').attr('readonly', true);
        $.ajax({
            type: "get",
            url: "/scheme/read_XML?jname="+'<%=jname%>'+"&sname="+'<%=sname%>',
            success: function(data) {
                document.getElementById("MeiShu").value=data.MeiShu;
                document.getElementById("FeiShu").value=data.FeiShu;
                document.getElementById("WidthResolution").value=data.WidthResolution;
                document.getElementById("WarpMiDu").value=data.WarpMiDu;
                document.getElementById("WeftMiDu").value=data.WeftMiDu;
                document.getElementById("Squeeze").value=data.Squeeze;
                document.getElementById("jname").value=data.jname;
                document.getElementById("sname").value=data.sname;
                $('#WarpColor').cxColor({
                    color:data.WarpColor
                });
                $('#WeftColor1').cxColor({
                    color:data.WeftColor1
                });
                $('#WeftColor2').cxColor({
                    color:data.WeftColor2
                });
                $('#WeftColor3').cxColor({
                    color:data.WeftColor3
                });
                $('#WeftColor4').cxColor({
                    color:data.WeftColor4
                });
            }

        });
    });

    function preview(){
        console.log(imgurl);
        window.location.href='../preview.jsp?url='+imgurl;
    }
    function edit(){
        $('input').attr('readonly', false);
    }
</script>
<style>
    .col-md-*{
        padding-left: 0px;
    }
    label{
        text-align: center;
    }
</style>
</body>
